perm filename EXTEND.RPG[UP,DOC] blob
sn#611711 filedate 1981-09-16 generic text, type T, neo UTF8
Functions:
PTR-TYPEP Primitive TYPE name for a datum -- see MC:NIL;NEWFUN >
for specifics. Currently, PTR-TYPEP is the same as the codes
actually stored in the "pointer" in the VAX NIL.
See *:VAX-PRIMITIVE-TYPES below.
EXTENDP
SI:EXTENDP A basic primitive type is the EXTEND, which is just a chunk
of index-access components, and a link to a descriptor object
which is itself another EXTEND. In fact, these "descriptor
objects" are essentially CLASSes in the LISPM and SMALLTALK
sense. In MacLISP, they are emulated with hunks.
EXTEND-LENGTH
SI:EXTEND-LENGTH The argument is an "instance" and this function just
counts the number of components in that instance.
SI:MAKE-EXTEND Takes two arguments -- first is CLASS object for which
an instance is being created, 2nd is number of "slots" to be
allocated in the instance.
SI:EXTEND First arg must be a CLASS -- remaining args are constructed
into an object of that CLASS; (SI:EXTEND SOME-CLASS 'T () )
would cons up a "SOME", and (SI:XREF frob 0) would get the 'T.
SI:XREF basic accessor for EXTENDs, e.g. (SI:XREF <ob> <index>)
SI:XSET basic updator, e.g. (SI:XSET <ob> <index> <val>)
CLASSP A predicate which is "true" iff its arg is not only an EXTEND,
but a class descriptor for some class of objects; such an
object, a CLASS object, will henceforth just be called a CLASS.
CLASS-OF For any argument, will return the CLASS for which that argument
is an instance; arguments of "primitive" type (i.e., not a
EXTEND) will be classified according to a systemic table,
whereas an EXTEND itself will have a direct link to its CLASS.
SEND Takes two or more arguments; the first is an object to
be acted upon, the second is a "keyword" which will be used
to select a method from among those accessible in the CLASS
of the first argument, and the remaining arguments are
just additional arguments to the method function.
SEND-AS Takes three or more arguments. Second arg is some object
to be acted upon (third is "keyword") just as with SEND, but
first argument is a CLASS which is to be the root for method
searching rather than the the class of the active object.
ADD-METHOD Takes args -- (<keyword> <fun> <class>) -- and stores the
function <fun> as a <keyword> method in the CLASS <class>.
Thus if SEND sends a message with the key <keyword> to an
object in the CLASS <class> (or to any object whose CLASS has
<class> as a superior class), then <fun> will be invoked.
There is an as-yet undocumented means for specifying the
method-searching function on a class by class basis.
FIND-METHOD (FIND-METHOD <msg> <class>) Returns the function
which will handle message <msg> for the CLASS <class>.
DESCRIBE Prints a brief description of the object; for EXTENDed
objects, retrieves some information from the corresponding
CLASS; for CLASS's themselves, will also do the DESCRIBE
operation for all its superiors.
WHICH-OPERATIONS For any object as argument, will print out a sequence
of lines with the (1) name of each "operation" (or message)
which is applicable to this object (as well as any object in
the same CLASS), (2) the name of the function which will handle
that operation, and (3) the name of the CLASS from which that
method was "inherited." See also SI:OPERATIONS-LIST below.
TYPE-OF Retrieves the TYPE name as stored in the CLASS for the datum
given as argument. For all MacLISP primitive datatypes (like,
SYMBOLs, BIGNUMS, etc), this will be the same as the TYPEP of
the datum.
EQ-FOR-EQUAL? Takes two args -- returns "true" only if EQ is
satisfactory for the EQUAL test (e.g., as on SYMBOLs).
SI:DEFCLASS*-1 Argspectrum is like (<typename> <class-var> <suprs>
&optional (<class-name> <typename>))
Normally, called by using the DEFCLASS* macro;
<typename> is a symbol to be used to describe the "type" of
objects and is stored in a slot of the CLASS retrieveable
by SI:CLASS-TYPEP and TYPE-OF (see below).
<class-var> is a symbol which will be set to the CLASS about
to be created; conventionally, if FOO is chosen as the
type name, then FOO-CLASS is the class variable.
<suprs> a list of CLASSes which are to be considered superiors
of this class (for the purposes of inheritance of
properties, such as "methods").
SI:HAS-SUPERIOR A predicate, "true" iff the second arg is some super-
class of the first arg. Both arguments must be classs.
SI:WHERE-IS-METHOD As above with SI:FIND-METHOD, but returns the actual
CLASS under which that function was stored as a method.
SI:OPERATIONS-LIST Argument must be a CLASS; returns a list of items
like `(,<key> ,<fun> ,<class>), where <key> is a method
name (or message key word), <fun> is the function which
handles that method, and <class> is the CLASS in which it was
found. <class> will either be the same as the argument, or
one of the superiors of the argument.
The following functions (which are SUBR's) also have macro definitions
which are "enabled" when compiling, to produce more efficient compiled code:
EXTEND-LENGTH, EXTENDP (merely produces call to the "SI:"-named versions)
SI:MAKE-EXTEND, SI:EXTEND, SI:XREF, and SI:XSET
Macros (only):
DEFCLASS* (DEFCLASS* <name> <variable> <superiors> . <options>) creates
a new CLASS named <name>, and putting it in the variable named
<variable>; the superior class may not be ommited. Typical
use might be
(DEFCLASS* MUMBLENUM MUMBLENUM-CLASS (NUMBER-CLASS))
[Note that the value of OBJECT-CLASS is the CLASS which is the
root of the CLASS hierarchy].
DEFMETHOD* Defines a method for a particular class, to be used when a
specified message is sent. For example,
(DEFMETHOD* (KEY FOO-CLASS) (OBJ . <arg-vars>)
. <body>)
defines a KEY method for instances of class FOO. Then when
(SEND <bar> 'KEY <a1> <a2>) is executed, OBJ is bound to <bar>,
the <arg-vars> are bound (or "spread-out") to <a1> and <a2>,
and <body> is executed. KEY can be a list of keys instead of
a single key.
TYPECASEQ Like CASEQ, but dispatches on the "primitive" type of the
datum. E.g., (TYPECASEQ X ((SYMBOL STRING) 5) (T 6))
could be emulated by (CASEQ (PTR-TYPEP X)
((SYMBOL STRING) 5)
(T 6))
In some implementations, however, this will be done by a
fast dispatch through a table, rather than by sequence of
EQ comparisons.
MAPF A generalized Mapper, usable on VECTORs, FIXNUMs, as well as
lists. See MC:NIL;NEWFUN > for more details.
**SELF-EVAL** Most EXTENDed data will have this symbol stored in
the (CXR 1 <obj>) slot. The macro-expansion of
(**SELF-EVAL** ...) yields (QUOTE (**SELF-EVAL** ...))
**CLASS-SELF-EVAL** Same as for **SELF-EVAL**, but used only in CLASS's --
this provides a simple heuristic to distinguish them quickly
from other hunks, and other EXTENDs
SI:EXTEND-CLASS-OF 1 arg. If object is know to be an EXTEND, this will
produce much faster code than calling CLASS-OF.
SI:CLASS-VAR
SI:CLASS-NAME
SI:CLASS-TYPEP
SI:CLASS-SUPERIORS Each CLASS (an EXTENDED data object which serves as
a descriptor for a whole class of objects) has about 17.
slots of data, the 5 more important of which are listed here
by the accessor macro names. Typically, each class has some
symbolic name, and some global variable whose value is that
class object; e.g. let <v> be the CLASS for VECTORs, then
(SI:CLASS-NAME <v>) ==> VECTOR, and
(SI:CLASS-VAR <v>) ==> VECTOR-CLASS
As a general convention, any class named FOO has the
class variable FOO-CLASS. The SI:CLASS-TYPEP component
is the value to be returned by TYPE-OF. SI:CLASS-SUPERIORS
is a list of CLASS's of which this one is a subclass;
primarily, the superiors are of interest when searching
for applicable methods, and the search goes "upwards" in
order to "inherit" properties from the superiors.
Variables:
NULL-CLASS CLASS for ()
PAIR-CLASS CLASS for non-null lists
and CLASS's for standard MacLISP data types:
FIXNUM-CLASS, FLONUM-CLASS, BIGNUM-CLASS, SYMBOL-CLASS, ARRAY-CLASS
HUNK-CLASS, SFA-CLASS, FILE-CLASS, JOB-CLASS, RANDOM-CLASS
*:TRUTH In MacLISP world, this is just "T", but in a real
NIL, it will be a new, unique constant to mean
"true"; "false" will still be represented by ().
*:VAX-PRIMITIVE-TYPES A list of SYMBOLs representing the names
of the data types whose type codes are stored in
in the "pointer" itself, for the VAX implementation
of NIL (i.e., not embedded as EXTENDs)
SI:INITIAL-CLASSES Holds a list of lists -- total of 22. -- each list
of which holds a little information about the initial
set up of the CLASS system; (mapcar 'CAR SI:INITIAL-CLASSES)
returns a list of the names of all initial CLASSes.
Error facilities:
Because the EXTEND facilities are designed to provide the MacLISP
user with some of the amenities of NIL or the LISPM, some extension
to the error system was needed, and it comes from the system file
LISP:CERROR -- CERROR and FERROR are supported, as on the LISPMachine,
but FORMAT is not forcibly loaded (it is called only when already loaded
so that one may use EXTENDs without having to load the humungous FORMAT file).
A few global variables are set up:
STANDARD-OUTPUT is set to T, and
ERROR-OUTPUT is set to a SFA which directs output to MSGFILES
βββ